package com.dfbz.homework5;

import org.junit.Test;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Scanner;

public class TestA{
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        //package com.dfbz.homework5.A
        System.out.println("请输入全名");
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
//        String aName = new Scanner(System.in).nextLine();//字符串录入类A的全名
        Class<?> aClass = Class.forName(s);//通过类A的全名获取字节码对象
        Constructor<?> constructor = aClass.getConstructor(String.class);
        A o = (A) constructor.newInstance("张三");
        o.show1();
    }
}
